﻿package org.openChart.meta
{
	import flash.text.StyleSheet;
	
	/**
	 * The style of any element.
	 * 
	 * @author Chongyuan
	 */
	public class Style 
	{
		// The color of element.
		public var color:uint;
		// The transparency of element.
		public var alpha:Number;
		// The color of element when it is selected.
		public var selectedColor:uint;
		// The transparency of element when it is selected.
		public var selectedAlpha:Number;
		// The size of element.
		public var size:uint;
		// The size of element when it is selected.
		public var selectedSize:uint;
		// The family the font to display.
		public var fontFamily:Number;
		// The size of font.
		public var fontSize:Number;
		// The width of element
		public var width:uint;
		// The height of element.
		public var height:uint;
		
		public var bold:Boolean;
		
		public var showValue:String;
		
		public var showLine:Boolean;
		
		public var offset:Number;
		
		public var viewAngle:Number;
		
		public var thickness:Number;
		
		/**
		 * The constructor of class Style.
		 * 
		 * @param	object  The sytle object.
		 */
		public function Style( object:Object = null, parent:Style = null ) 
		{
			if (parent) {
				this.color = parent.color;
				this.alpha = parent.alpha;
				this.selectedColor = parent.selectedColor;
				this.selectedAlpha = parent.selectedAlpha;
				this.size = parent.size;
				this.selectedSize = parent.selectedSize;
				this.fontFamily = parent.fontFamily;
				this.fontSize = parent.fontSize;
				this.width = parent.width;
				this.height = parent.height;
				this.bold = parent.bold;
				this.showLine = parent.showLine;
				this.showValue = parent.showValue;
				this.offset = parent.offset;
				this.viewAngle = parent.viewAngle;
				this.thickness = parent.thickness;
			}
			this.init(object);
		}
		
		/**
		 * 
		 * @param	object
		 */
		public function setStyle( object:Object ):void
		{
			this.init( object );
		}
		
		/**
		 * 
		 * @return Object The style as object.
		 */
		public function getStyle():Object
		{
			return null;
		}
		
		/**
		 * Parse the style to string.
		 * 
		 * @return String The style string.
		 */
		public function getStyleAsString():String
		{
			return null;
		}
		/**
		 * The initial funtion of class Style.
		 * @param	object  The sytle object.
		 */
		private function init( object:Object ):void
		{
			//trace(this + object.showValue);
			if (object) 
			{
				if (object.color)
					this.color = object.color;
				if (object.alpha)
					this.alpha = object.alpha;
			    if (object.selectedAlpha)
					this.selectedAlpha = object.selectedAlpha;
				if (object.selectedColor)
					this.selectedColor = object.selectedColor;
				if (object.size)
					this.size = object.size;
				if (object.selectedSize)
					this.selectedSize = object.selectedSize;
				if (object.fontFamily)
					this.fontFamily = object.fontFamily;
				if (object.fontSize)
					this.fontSize = object.fontSize;
				if (object.bold)
					this.bold = object.bold;
				if (object.width)
					this.width = object.width;
				if (object.height)
					this.height = object.height;
				if (object.bold)
					this.bold = object.bold;
				if (object.showLine)
					this.showLine = object.showLine;
				if (object.showValue)
					this.showValue = object.showValue;
				if (object.offset)
					this.offset = object.offset;
				if (object.viewAngle)
					this.viewAngle = object.viewAngle;
				if (object.thickness)
					this.thickness = object.thickness;
			}
		}
		
	}
	
}